package com.suli.multimedia.entity;

import com.baomidou.mybatisplus.annotation.*;

import java.io.Serializable;
import java.util.Date;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.suli.multimedia.enums.ArticleType;
import lombok.*;

/**
 * <p>
 * 
 * </p>
 *
 * @author SuLi
 * @since 2022-03-17
 */
@Getter
@Setter
@TableName("article")
@ToString
@NoArgsConstructor
@AllArgsConstructor
public class Article implements Serializable {

    private static final long serialVersionUID = 1L;

    /**
     *文章id
     */
    @TableId(value = "article_id", type = IdType.AUTO)
    private Integer articleId;

    /**
     * 文章类型
     */
    @TableField("article_type")
    private ArticleType articleType;

    /**
     * 文章发布者
     */
    @TableField("user_id")
    private String userId;

    /**
     * 文章标题
     */
    @TableField("article_title")
    private String articleTitle;

    /**
     * 文章发布时间
     */
    @TableField(value = "publish_time", fill = FieldFill.INSERT)
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone="GMT+8")
    private Date publishTime;

    /**
     * 逻辑删除
     */
    @TableField(value = "is_deleted",fill = FieldFill.INSERT)
    @TableLogic
    private Integer isDeleted;

    /**
     * 文章观看数
     */
    @TableField(value = "views",fill = FieldFill.INSERT)
    private Integer views;

    public Article(String userId, String articleTitle,ArticleType articleType) {
        this.articleType = articleType;
        this.userId = userId;
        this.articleTitle = articleTitle;
    }
}
